#include "StdAfx.h"
#include "EditorPropViewer.h"
#include "PropFactory.h"
#include "PropHolder.h"
#include "VarList.h"
#include "ShapeBuilder.h"
CEditorPropViewer::CEditorPropViewer(CAnyEditor* pEditor, CPropHolder* pProp)
{
	m_pProp = pProp;
	m_pEditor = pEditor;
	m_pVarList = new CVarList();
}

CEditorPropViewer::~CEditorPropViewer(void)
{
	delete m_pVarList;
	delete m_pProp;
}

void CEditorPropViewer::OnParamChanged(UINT nID)
{
	CShapeInfo* pInfo = m_pEditor->GetShapeInfo();

	if(pInfo && m_pProp->IsValid())
	{
		pInfo->GetParams(*m_pVarList, nID);
		m_pProp->SetValues(*m_pVarList);
	}
}

void CEditorPropViewer::OnChangeParam(UINT nID)
{
	_variant_t value;
	if(m_pProp->GetItemValue(nID, value))
	{
		m_pVarList->SetValue(nID, value);
		CShapeInfo* pInfo = m_pEditor->GetShapeInfo();
		if(pInfo)
			pInfo->SetParams(*m_pVarList, nID);
	}
}

void CEditorPropViewer::Show()
{
	OnParamChanged(0);
}